package com.homework.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.homework.entity.ClassSchedule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClassScheduleMapper extends BaseMapper<ClassSchedule> {

    /**
     * 根据学生ID获取课程表
     */
    @Select("SELECT * FROM class_schedule WHERE student_id = #{studentId} AND is_active = true ORDER BY day_of_week, session_order")
    List<ClassSchedule> selectByStudentId(@Param("studentId") Long studentId);

    /**
     * 根据学生ID和星期几获取课程
     */
    @Select("SELECT * FROM class_schedule WHERE student_id = #{studentId} AND day_of_week = #{dayOfWeek} AND is_active = true ORDER BY session_order")
    List<ClassSchedule> selectByStudentIdAndDay(@Param("studentId") Long studentId, @Param("dayOfWeek") Integer dayOfWeek);

    /**
     * 根据学生ID删除所有课程表
     */
    @Select("DELETE FROM class_schedule WHERE student_id = #{studentId}")
    int deleteByStudentId(@Param("studentId") Long studentId);
}